package com.xzx.shop_front_api.mapper;

import com.xzx.shop_front_api.entity.News;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface NewsMapper {
    @Insert("INSERT INTO news (title, content, cate_id, create_time) VALUES (#{title}, #{content}, #{cateId}, #{createTime})")
    int insert(News news);

    @Select("SELECT * FROM news WHERE id = #{id}")
    News selectById(int id);

    @Delete("DELETE FROM news WHERE id = #{id}")
    int deleteById(int id);

    @Select("SELECT * FROM news")
    List<News> selectAll();
}
